home *** CD-ROM | disk | FTP | other *** search
/ Aminet 39 / Aminet 39 (2000)(Schatztruhe)[!][Oct 2000].iso / Aminet / dev / c / ExtrasLib.lha / ExtrasLib / Include / Extras / threads.h < prev   
Encoding:
C/C++ Source or Header  |  2000-07-17  |  1.9 KB  |  87 lines

  1. #ifndef EXTRAS_THREADS_H
  2. #define EXTRAS_THREADS_H
  3.  
  4. #ifndef EXEC_NODES_H
  5. #include "exec/nodes.h"
  6. #endif /* EXEC_NODES_H */
  7.  
  8. #ifndef EXEC_LISTS_H
  9. #include "exec/lists.h"
  10. #endif /* EXEC_LISTS_H */
  11.  
  12. #ifndef EXEC_TASKS_H
  13. #include "exec/tasks.h"
  14. #endif /* EXEC_TASKS_H */
  15.  
  16. #ifndef EXEC_PORTS_H
  17. #include <exec/ports.h>
  18. #endif
  19.  
  20. #ifndef UTILITY_TAGITEM_H
  21. #include <utility/tagitem.h>
  22. #endif
  23.  
  24. /* TAGS */
  25. #define TA_DUMMY(x)    (TAG_USER + (x))
  26.                                    // Defaults
  27. #define TA_Name       TA_DUMMY(1) // "Thread"
  28. #define TA_Stack      TA_DUMMY(2) // 8192
  29. #define TA_Priority   TA_DUMMY(3) // -1
  30.  
  31. //#define TA_Entry      TA_DUMMY(4) // Entry
  32. #define TA_MsgHandler TA_DUMMY(5) // Required
  33.  
  34. #define TA_UserData   TA_DUMMY(6) // (APTR)
  35.  
  36. /* Proto for thread entry
  37.  
  38. ULONG __asm __saveds ThreadDispatch( register __a0 struct Thread *T,
  39.                                      register __a1 struct ThreadMessage *TMsg)
  40.  
  41. */
  42.  
  43. /* Readable ONLY unless otherwise marked */
  44. struct Thread
  45. {
  46.   struct Node t_Node; // Application use
  47.   STRPTR TName; 
  48.   struct Process *t_Process;
  49.   struct MsgPort *t_MsgPort;
  50.   APTR   UserData;    // Application use
  51.   APTR   ThreadData;  // App/Thread use
  52. };
  53.  
  54. // ThreadMessage.tm_Command
  55. #define TMSG_INTERNAL_BIT TMSG_DUMMY(0)  // User messages must not have this bit set.
  56.  
  57. #define TMSG_DUMMY(x)     ((1<<31) + (x))
  58. #define TMSG_DIE          TMSG_DUMMY(1)  // All threads shoul respect this message.
  59. #define TMSG_SIGNAL       TMSG_DUMMY(2)  // Thread has been Signaled.
  60. #define TMSG_SIGNALED     TMSG_DUMMY(2)  // Thread has been Signaled.
  61.  
  62. /* Basic thread message */
  63. struct ThreadMessage
  64. {
  65.   struct Message  tm_Msg;
  66.   ULONG           tm_Command;
  67.   // User data follows
  68. };
  69.  
  70. struct TMsg_TagList
  71. {
  72.   struct Message  tm_Msg;
  73.   ULONG           tm_Command,
  74.                   tm_RetVal;
  75.   struct TagItem  *tm_TagList;
  76. };
  77.  
  78. struct TMsg_Signal
  79. {
  80.   struct ThreadMessage TMsg;
  81.   ULONG  Signal;
  82. };
  83.  
  84.  
  85.  
  86. #endif /* EXTRAS_THREADS_H */
  87.